home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Complementary Applications 2004 February / SGI IRIX 6.5 Complementary Applications 2004 February.iso / dist / cde.idb / usr / dt / share / man / cat3 / XmResolveAllPartOffsets.z / XmResolveAllPartOffsets
Encoding:
Text File  |  2003-11-18  |  8.8 KB  |  199 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       _X_m_R_e_s_o_l_v_e_A_l_l_P_a_r_t_O_f_f_s_e_t_s - A function that allows writing of
  10.       upward-compatible applications and widgets
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.       #include <Xm/XmP.h>
  14.  
  15.       void XmResolveAllPartOffsets (wwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss,,,, ooooffffffffsssseeeetttt,,,, ccccoooonnnnssssttttrrrraaaaiiiinnnntttt____ooooffffffffsssseeeetttt)
  16.            _W_i_d_g_e_t_C_l_a_s_swwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss;
  17.            _X_m_O_f_f_s_e_t_P_t_r**** ooooffffffffsssseeeetttt;
  18.            _X_m_O_f_f_s_e_t_P_t_r**** ccccoooonnnnssssttttrrrraaaaiiiinnnntttt____ooooffffffffsssseeeetttt;
  19.  
  20.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  21.       The use of offset records requires two extra global
  22.       variables per    widget class.  The variables consist of
  23.       pointers to arrays of    offsets    into the widget    record and
  24.       constraint record for    each part of the widget    structure.
  25.       The _X_m_R_e_s_o_l_v_e_A_l_l_P_a_r_t_O_f_f_s_e_t_s function allocates the offset
  26.       records needed by an application to guarantee    upward-
  27.       compatible access to widget instance and constraint records
  28.       by applications and widgets.    These offset records are used
  29.       by the widget    to access all of the widget's variables.  A
  30.       widget needs to take the following steps:
  31.  
  32.       +o    Instead of creating a resource list, the    widget creates
  33.            an offset resource list.     To help you accomplish    this,
  34.            use the _X_m_P_a_r_t_R_e_s_o_u_r_c_e structure    and the    _X_m_P_a_r_t_O_f_f_s_e_t
  35.            macro.  The _X_m_P_a_r_t_R_e_s_o_u_r_c_e data structure looks just
  36.            like a resource list, but instead of having one integer
  37.            for its offset, it has two shorts.  This    is put into
  38.            the class record    as if it were a    normal resource    list.
  39.            Instead of using    _X_t_O_f_f_s_e_t for the offset, the widget
  40.            uses _X_m_P_a_r_t_O_f_f_s_e_t.
  41.  
  42.       If the widget    is a subclass of the Constraint    class and it
  43.       defines additional constraint    resources, create an offset
  44.       resource list    for the    constraint part    as well.  Instead of
  45.       using    _X_t_O_f_f_s_e_t for the offset, the widget uses
  46.       _X_m_C_o_n_s_t_r_a_i_n_t_P_a_r_t_O_f_f_s_e_t in the    constraint resource list.
  47.       XmPartResource resources[] = {
  48.         {  BarNxyz,    BarCXyz, XmRBoolean, sizeof(Boolean),
  49.            XmPartOffset(Bar,xyz), XmRImmediate, (XtPointer)False } };
  50.  
  51.       XmPartResource constraints[] = {
  52.         {  BarNmaxWidth, BarNMaxWidth,
  53.             XmRDimension, sizeof(Dimension),
  54.             XmConstraintPartOffset(Bar,max_width),
  55.             XmRImmediate, (XtPointer)100 } };
  56.  
  57.       +o    Instead of putting the widget size in the class record, the widget puts the
  58.            widget part size    in the same field.
  59.            If the widget is    a subclass of
  60.            the Constraint class, instead of    putting    the widget constraint record
  61.  
  62.  
  63.      Page 1                        (printed 11/11/03)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  71.  
  72.  
  73.  
  74.            size in the class record, the widget puts the widget constraint part size
  75.            in the same field.
  76.  
  77.       +o    Instead of putting _X_t_V_e_r_s_i_o_n in the class record, the widget puts
  78.            _X_t_V_e_r_s_i_o_n_D_o_n_t_C_h_e_c_k in the class record.
  79.  
  80.       +o    Define a    variable, of type _X_m_O_f_f_s_e_t_P_t_r, to point    to
  81.            the offset record.
  82.            If the widget is    a subclass of the Constraint class, define a variable
  83.            of type XmOffsetPtr to point to the constraint offset record.
  84.            These can be part of the    widget's class record or separate global
  85.            variables.
  86.  
  87.       +o    In class    initialization,    the widget calls _X_m_R_e_s_o_l_v_e_A_l_l_P_a_r_t_O_f_f_s_e_t_s,
  88.            passing it pointers to the class    record,    the address of the offset
  89.            record, and the address of the constraint offset    record.
  90.            If the widget not is a subclass of the Constraint class,    it should pass
  91.            NULL as the address of the constraint offset record.
  92.            This does several things:
  93.  
  94.       Adds the superclass (which, by definition, has already been initialized)
  95.       size field to    the part size field
  96.  
  97.       If the widget    is a subclass of the Constraint    class, adds the    superclass
  98.       constraint size field    to the constraint size field
  99.  
  100.       Allocates an array based upon    the number of superclasses
  101.  
  102.       If the widget    is a subclass of the constraint    class, allocates an array
  103.       for the constraint offset record
  104.  
  105.       Fills    in the offsets of all the widget parts and constraint parts with
  106.       the appropriate values, determined by    examining the size fields of all
  107.       superclass records
  108.  
  109.       Uses the part    offset array to    modify the offset entries in the resource
  110.       list to be real offsets, in place
  111.  
  112.       +o    The widget defines a constant which will    be the index to    its part
  113.            structure in the    offsets    array.
  114.            The value should    be 1 greater than
  115.            the index of the    widget's superclass.
  116.            Constants defined for all Xm
  117.            widgets can be found in _X_m_P._h.
  118.            #define BarIndex    (XmBulletinBIndex + 1)
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 11/11/03)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVVXXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  137.  
  138.  
  139.  
  140.       +o    Instead of accessing fields directly, the widget    must always go through
  141.            the offset table.
  142.            The _X_m_F_i_e_l_d and _X_m_C_o_n_s_t_r_a_i_n_t_F_i_e_l_d macros    help you access
  143.            these fields.
  144.            Because the _X_m_P_a_r_t_O_f_f_s_e_t, _X_m_C_o_n_s_t_r_a_i_n_t_P_a_r_t_O_f_f_s_e_t,
  145.            _X_m_F_i_e_l_d,    and _X_m_C_o_n_s_t_r_a_i_n_t_F_i_e_l_d
  146.            macros concatenate things together, you must ensure that    there is no space
  147.            after the part argument.
  148.            For example, the    following macros do not    work because of    the space
  149.            after the part (Label) argument:
  150.            XmField(w, offset, Label    , text,    char *)
  151.            XmPartOffset(Label , text).
  152.            Therefore, you must not have any    spaces after the part (Label)
  153.            argument, as illustrated    here:
  154.            XmField(w, offset, Label, text, char *)
  155.            You can define macros for each field to make this easier.
  156.            Assume an integer field xxxxyyyyzzzz:
  157.            #define BarXyz(w) (*(int    *)(((char *) w)    + \
  158.          offset[BarIndex] + XtOffset(BarPart,xyz)))
  159.  
  160.       For constraint field mmmmaaaaxxxx____wwwwiiiiddddtttthhhh:
  161.       #define BarMaxWidth(w) \
  162.         XmConstraintField(w,constraint_offsets,Bar,max_width,Dimension)
  163.  
  164.       The parameters for _X_m_R_e_s_o_l_v_e_A_l_l_P_a_r_t_O_f_f_s_e_t_s are defined below:
  165.  
  166.       wwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss
  167.            Specifies the widget class pointer for the created widget
  168.  
  169.       ooooffffffffsssseeeetttt
  170.            Returns the offset record
  171.  
  172.       ccccoooonnnnssssttttrrrraaaaiiiinnnntttt____ooooffffffffsssseeeetttt
  173.            Returns the constraint offset record
  174.  
  175.      RRRREEEELLLLAAAATTTTEEEEDDDD IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  176.       _X_m_R_e_s_o_l_v_e_P_a_r_t_O_f_f_s_e_t_s(_3_X).
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                        (printed 11/11/03)
  196.  
  197.  
  198.  
  199.